<!doctype html>
<html >
<head>
	<meta charset="UTF-8">
	<title class="systemname">RPA机器人工作台</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=1.0" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="stylesheet" href="/rpa_work/static/css/xadmin.css?v=1.01">
    <script type="text/javascript" src="/rpa_work/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="/rpa_work/static/js/jquery.cookie.js"></script>
    <script src="/rpa_work/static/layui/layui.js?v=2.6.8" charset="utf-8"></script>
    <script>var page="login";</script>
	<script type="text/javascript" src="/rpa_work/static/js/xadmin.js?v=1.0"></script>
</head>
<body class="login-bg">
    <div class="login-box layui-anim layui-anim-up">
    <div class="layui-row">
        <div class="login layui-col-xs12">
            <div class="message" id="message">欢迎登录<span class="systemname">RPA机器人工作台</span></div>      
            <form method="post" class="layui-form layui-form-pane" onsubmit="return false;"  >
                  <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                      <input type="text" name="username" required  lay-verify="required" placeholder="用户名" lay-reqText="用户名不能为空" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                      <input type="password" name="password" required lay-verify="required" placeholder="密码" lay-reqText="密码不能为空" autocomplete="off" class="layui-input">
                    </div>
                  </div>
              <div class="layui-form-item">
                  <button class="layui-btn" lay-submit lay-filter="login">登录</button>
              </div>
            </form>
            </div>
       </div>
        <div class="copyright" id="copyright">Tiger-Tail RPA PWA <span class="version">1.0</span></div>
    </div>

    <script>
        $(function  () {
			if (window != top)top.location.href = location.href;

            layui.use('form', function(){
              var form = layui.form;

              //监听提交
              form.on('submit(login)', function(data){
                  $.ajax({
                    url: apiurl+"login",
                    type: 'POST',
                    dataType: 'json',
                    data: JSON.stringify(data.field),
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    success: function(res) {
                                     if(res.status==0){
                                        $.cookie('user_name',res.user_name,{path: '/'});
                                        $.cookie('sid',res.sid,{path: '/'});
                                        layer.msg('欢迎回来，'+res.user_name);
                                        window.location.href="/rpa_work/static/page/index.html";
                                     }else{
                                        layer.msg(res.msg);
                                     }
                    },
                    error: function(xhr, status, error) {
                        layer.msg(error);
                    }
                });
				
                return false;
              });
            });
        })

        
    </script>

    
 
</body>
</html>